package cn.me.alphamq.common.model.broker;

import java.util.List;

/**
 * CommitLog 的 topic 的模型
 *
 * @author f
 */
public class CommitLogTopicModel {

    /**
     * topic 名称
     */
    private String topic;

    /**
     * CommitLog 文件
     */
    private CommitLogFileModel commitLogFileModel;

    /**
     * 订阅本 topic 的 queue 队列
     */
    private List<ConsumeQueueFileModel> queueList;

    /**
     * 创建时间
     */
    private Long createAt;

    /**
     * 修改时间
     */
    private Long updateAt;

    /**
     * 通过 队列 id 获取指定的 ConsumeQueue 文件
     *
     * @param queueId
     * @return
     */
    public ConsumeQueueFileModel fetchConsumeQueueFileByQueueId(Integer queueId) {
        return queueList.stream().filter(item -> item.getId().equals(queueId)).findFirst().orElse(null);
    }

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }

    public CommitLogFileModel getCommitLogFileModel() {
        return commitLogFileModel;
    }

    public void setCommitLogFileModel(CommitLogFileModel commitLogFileModel) {
        this.commitLogFileModel = commitLogFileModel;
    }

    public List<ConsumeQueueFileModel> getQueueList() {
        return queueList;
    }

    public void setQueueList(List<ConsumeQueueFileModel> queueList) {
        this.queueList = queueList;
    }

    public Long getCreateAt() {
        return createAt;
    }

    public void setCreateAt(Long createAt) {
        this.createAt = createAt;
    }

    public Long getUpdateAt() {
        return updateAt;
    }

    public void setUpdateAt(Long updateAt) {
        this.updateAt = updateAt;
    }

    @Override
    public String toString() {
        return "TopicModel{" +
                "topic='" + topic + '\'' +
                ", commitLogFileModel=" + commitLogFileModel +
                ", queueList=" + queueList +
                ", createAt=" + createAt +
                ", updateAt=" + updateAt +
                '}';
    }
}
